<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ include file="/WEB-INF/common/common.jsp"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>${serviceForm.formName }</title>
<link href="<%=path %>/css/style.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="<%=path %>/js/jquery-1.8.0.min.js"></script>
<script type="text/javascript" src="<%=path %>/js/common.js"></script>
<script type="text/javascript" src="<%=path %>/third/layer-v1.9.3/layer.js"></script>
<script type="text/javascript">
/*
 *_contextPath:上下文路径
 *_modulePath: 模块路径
 */
var  _contextPath="<%=path%>";
var  _modulePath=_contextPath+"/sys/";
$(document).ready(function(){
  $(".clicks").click(function(){
   _open(_modulePath+"textures_open.action?view=add");
  });
});
</script>
<!-- ****************动态添加新的元素开始******************************* -->

<script type="text/javascript">
var fieldNum=parseInt("${serviceForm.fieldNum}");
 $(function(){
	  $(".addForm").live("click",function(){
	      fieldNum++;
		  $("#tab").append("<tr>"+
			  "<td>"+
			  "<input type='hidden' class='fValue' value='new'/>"+
			  "<input type='text' class='dfinputformselect fName' placeholder='请填写字段名 'style='font-size:15px' id='f2'/>"+
			  "<div class='autocompleter' "+
			  "</div>"+
			  "<span id=''>"+
			  "</span>"+
			  "</td>"+
			  /* 字段名打印结束 */
			  "<td>"+
			  "<select class='dfinputformselect fType' style='font-size:15px'>"+
			  "<option value='0' selected='selected'style='font-size:15px'>"+
			  "文字"+
			  "</option>"+
			  "<option value='1'style='font-size:15px'>"+
			  "数字"+
			  "</option>"+
			  "<option value='2'style='font-size:15px'>"+
			  "时间"+
			  "</option>"+
			  "</select>"+
			  "</td>"+
			  /* 选择字段类型打印结束 */
			  "<td>"+
			  "<input class='dfinputformselect fLen' type='text' placeholder='请填写字段的长度' value='20'style='font-size:15px'/>"+
			  "<span id='msgNumber'>"+
			  "</span>"+
			  "</td>"+
			  /* 填写字段长度打印结束 */
			  "<td>"+
			  "<a href='#' class='delete'>"+
			  "<font color='#FF0000'style='font-size:15px'>"+
			  "&nbsp;删除字段"+
			  "</font>"+
			  "</a>"+
			  "&nbsp;&nbsp;&nbsp;&nbsp;"+
			  "<a href='#' class='addForm'>"+
			  "<font color='blue'style='font-size:15px'>"+
			  "&nbsp;添加字段"+
			  "</font>"+
			  "</a>"+
			  "</td>"+
			  "</tr>"
			  /*添加、删除打印结束  */
		  );
		
  	});
 });
 
 $(function(){
 	$(".save").click(function(){
	 	var fn="";
	 	var ft="";
	 	var fl="";
	 	var fv="";
 		$(".fName").each(function(){
			fn = fn + $(this).val()+",";
 		});
 		$(".fType").each(function(){
			ft = ft + $(this).val()+",";
 		});
 		
 		$(".fLen").each(function(){
			fl = fl + $(this).val()+",";
 		});
 		$(".fValue").each(function(){
			fv = fv + $(this).val()+",";
 		});
 		$("#fieldForm").append("<input type='hidden' name='fieldNames' value='"+
 								fn+
 								"'/>" +
 								"<input type='hidden' name='fieldType' value='"+
 								ft+
 								"'/>"+
 								"<input type='hidden' name='fieldLen' value='"+
 								fl+
 								"'/>"+
 								"<input type='hidden' name='fieldValue' value='"+
 								fv+
 								"'/>"+
 								"<input type='hidden' name='fieldNum' value='"+
 								fieldNum+
 								"'/>"
 								);
 		
 		
 		//	$("#fieldForm").submit();
 	}); 
 	
 	//刪除
 	$("#tab").delegate(".delete","click",function(){
 		if(fieldNum == 1){
 			alert("表格中至少有一个字段，无法继续删除");
 		}else{
 		 $(this).parent().parent().remove();
 		fieldNum--;
 		}

 	});
 	
 });
 
</script>
<!-- ****************动态添加新的元素结束******************************* -->
<!-- ****************当前页面表单校验开始******************************* -->
<script type="text/javascript">
	$(document).ready(function(){	
	   $("#formName").each(function(){	 	
       $(this).after("<font  color='#FF0000' style='font-size:20px' id='f1'>&nbsp;&nbsp;*&nbsp;&nbsp;</font>");      
	 }); 	 
	 $("#formName").blur(function(){	 
		 $("#f1").remove();	 
			 if(this.value =="")
			 {
			    $(this).after("<font  color='#FF0000' style='font-size:15px' class = 'f1' id = 'f1'>&nbsp;&nbsp;表格名字不能为空！</font>");
			 }
	 
	 });	 
	});
	$("#save").live('click',function(){
		$("#formName").trigger("blur");
		var flag = $(".f1").length;
		console.log("======flag"+flag);
			if(flag==0){
			$("#fieldForm").submit();
			}
	});

</script>
<!-- ****************当前页面表单校验结束******************************* -->

<script type="text/javascript">

   /* 导入Excel弹框 */
	function choice(title,url,w,h){	
		layer.open({
		  type: 2,
		  area: ['85%', '80%'],
		  fixed: false,    //弹框位置不固定
		  maxmin: true,
		  content: url
		});	
	}
	
</script>

<style type="text/css">
<style type="text/css">
.tablelinkdelete{color:#056dae;}
</style>
 <style>
    textarea{
    color:#000000;
    border-top:solid 1px #a7b5bc;
    border-left:solid 1px #a7b5bc;
    border-right:solid 1px #ced9df;
    border-bottom:solid 1px #ced9df;
    font-size:12px; 
     width:80%;
     height:800;
      } 
     .special{
            font-size: 18px;
            font-family:'微软雅黑';
            font-style: normal;           
        }                  
 </style>

</head>
<body>
	<div class="place">
    <span>位置：</span>
    <ul class="placeul">
    <li><a href="#">首页</a></li>
    <li><a href="#">表格管理</a></li>
    <li><a href="#">修改任务格式</a></li>
    </ul>
    </div>
<div class="formbody">
    <div id="usual" class="usual">
      <div id="tab2" class="tabson">
        
     	<form id="fieldForm" action="<%= basePath%>/biz/ServiceForm_editTaskForm.action" method="post"  target="rightFrame">
                 <input name="serviceForm.formId" type="hidden" value="${serviceForm.formId }"/>
                 <input name="serviceTask.taskId" type="hidden" value="${serviceTask.taskId }"/>
            <font style='font-size:15px'>表格名字：</font>
            <input type="text" name="serviceForm.formName"   id="formName"  autocomplete="off" value="${serviceForm.formName }" placeholder="请输入表格名称" class="dfinputform" style='font-size:15px'/>
            
    					<div class="autocompleter" id="autocompleter-1">
							<ul class="autocompleter-list">
								<li class="autocompleter-item"></li>
							</ul>  
							<tr>&nbsp;</tr>  
							<tr>&nbsp;</tr>   
							<tr>&nbsp;</tr>             
  
   
    <table class="tablelistform"id="tab">
    	<thead>
    	<tr>
    
         <th><font style='font-size:18px'>字段名</font></th>
   	     <th><font style='font-size:18px'>字段类型</font></th>
   		 <th><font style='font-size:18px'>字段长度</font></th>   				
   		 <th><font style='font-size:18px'>操作</font></th>
        </tr>
        
        </thead>
        <tbody>
      
      <s:iterator value="fieldList">
      
          <tr>   	
          			
    				<td>
    					<input type="hidden" class="fValue" value="${value }"/>
    					
    					<input type="text" class="dfinputformselect fName" autocomplete="off" value="${name }" placeholder="请填写字段名"style='font-size:15px'id='f2'/>
    					<div class="autocompleter" id="autocompleter-1">
							<ul>							
							</ul>
						</div> 
    					<span id="msgSeleDrug"></span>
    				</td>   				
    				<td>
    					<select class="dfinputformselect fType" id="fieldType"style='font-size:15px'>
    					 <c:choose>
						<c:when test="${0 == type }">
							<option value="0" selected="selected"style='font-size:15px'>文字</option>
    						<option value="1"style='font-size:15px'>数字</option>
    						<option value="2"style='font-size:15px'>时间</option>
    					</c:when>
						<c:when test="${1 == type }">
							<option value="0"style='font-size:15px'>文字</option>
    						<option value="1" selected="selected"style='font-size:15px'>数字</option>
    						<option value="2"style='font-size:15px'>时间</option>
						</c:when>
						<c:when test="${2 == type }">
							<option value="0"style='font-size:15px'>文字</option>
    						<option value="1"style='font-size:15px'>数字</option>
    						<option value="2" selected="selected"style='font-size:15px'>时间</option>
    					</c:when>
						</c:choose> 
						
    					</select>
    				</td>
    				<td> 
    				<input  type="text" class="dfinputformselect fLen" id ="fieldLen" placeholder="请填写字段长度" value="${len }" style='font-size:15px'/>
    					<span id="msgNumber" ></span>
    				</td>
    				   				
    				<td>
    					<a href="#" class="delete"><font  color="#FF0000"style='font-size:15px'>&nbsp;删除字段</font></a>
    					&nbsp;&nbsp;&nbsp;
    					<a href="#" class="addForm"><font  color="blue"style='font-size:15px'>添加字段</font></a>
    					
    				</td>
    		
       	 </tr> 
    	</s:iterator>
        </tbody>
    </table>
    <tr>&nbsp;</tr>
    
     <li class="special"><img src="<%=path%>/images/t02.png" />填写备注</li> 
    <textarea name="serviceForm.remark" rows="10" cols="55" style='font-size:18px'>${serviceForm.remark }</textarea>
    <tr>&nbsp;</tr>
    <br />
    <br />
    <br />
    
   <ul class="forminfo"> <li><label>&nbsp;</label><input name="" type="button" class="btn save" value="确认保存" id='save'/>
			&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp<input name="" type="button" class="scbtn" value="上传模板" onclick="choice('上传Excel','ServiceUpload_openAdd.action','800','510')"/></li>
			</ul>
   
   
        </form> 
    
      <%--   <form action="<%= basePath%>/biz/ServiceUpload_openAdd.action" method="post">
        <input name="" type="submit" class="btn upload" value="上传Excel" />
        </form> --%>
  </div>  
       
	</div>
    
<%
//查询的url地址，统一写
String listActionURL = basePath+"/biz/ServiceForm.action";
%>
 
<!-- <script type="text/javascript"> 
      $("#usual1 ul").idTabs(); 
    </script> -->
    
    <script type="text/javascript">
	$('.tableaddlist tbody tr:odd').addClass('odd');
	</script>
</div>
	  <div class="tip">
    	<div class="tiptop"><span>提示信息</span><a></a></div>
        <div class="tipinfo">
        <span><img src="<%= basePath%>images/ticon.png" /></span>
        <div class="tipright">
        <p>是否确认删除信息 ？</p>
        <cite>如果是请点击确定按钮 ，否则请点取消。</cite>
        </div>
        </div>
        
        <div class="tipbtn">
        <input name="" type="button"  class="sure" value="确定" />&nbsp;
        <input name="" type="button"  class="cancel" value="取消" />
        </div>
    
    </div>
	

</body>

</html>
